package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.dao.core.AccountSmsModelDao;
import com.tbit.uqbike.client.pojo.AccountSmsModel;
import com.tbit.uqbike.client.service.AccountSmsModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: ShiGuang
 * @create: 2021-12-28 11:50
 * @description: 获取其他短信配置模板和内容
 */
@Service
public class AccountSmsModelServiceImpl implements AccountSmsModelService {

    @Autowired
    private AccountSmsModelDao accountSmsModelDao;

    /**
     * 根据品牌id和类型，获取短信模板
     *
     * @param accountId
     * @param smsType
     * @return
     */
    @Override
    public AccountSmsModel getByAccountIdAndType(Integer accountId, Integer smsType) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("accountId", accountId);
        params.put("smsType", smsType);
        return accountSmsModelDao.getByAccountIdAndType(params);
    }

    /**
     * 根据品牌
     *
     * @param accountId
     * @return
     */
    @Override
    public List<AccountSmsModel> getByAccountId(Integer accountId) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("accountId", accountId);
        return accountSmsModelDao.getByAccountId(params);
    }

    /**
     * 根据类型查询短信
     *
     * @param smsType
     * @return
     */
    @Override
    public List<AccountSmsModel> getByAll(Integer smsType) {
        List<AccountSmsModel> accountSmsModelList = accountSmsModelDao.getByAll(smsType);
        for (AccountSmsModel accountSmsModel : accountSmsModelList) {
            if (accountSmsModel.getSmsCodeKey() == null || accountSmsModel.getSmsModelId() == null || accountSmsModel.getAccountId().equals(100019)) {
                accountSmsModel.setSmsCodeKey("5f272cb18fac070fbefb93121afc4916");
                accountSmsModel.setSmsModelId("92153");
            }
        }
        return accountSmsModelList;
    }

    /**
     * 获取所有
     *
     * @return
     */
    @Override
    public List<AccountSmsModel> getSmsModelByAll() {
        return accountSmsModelDao.getSmsModelByAll();
    }
}